import { IAuthLoader } from '@/router/AuthLoader'
import { useRouteLoaderData } from 'react-router-dom'
import { Button, Divider } from 'antd'
import { useStore } from '@/store/index'
/*
 * @Description: 描述信息
 * @Version: 版本号
 * @Author: xuebao
 * @Date: 2023-12-13 22:11:10
 * @LastEditors: xuebao
 * @LastEditTime: 2023-12-13 22:16:17
 */
export default function AuthButton(props: any) {
  const role = useStore((state) => state.userInfo.role)
  //role === 1代表的是管理员 也可以使用按钮
  const data = useRouteLoaderData('layout') as IAuthLoader
  if (!props.auth) return <Button {...props}>{props.children}</Button>
  if (data.buttonList.includes(props.auth) || role == 1) return <Button {...props}>{props.children}</Button>
  return <></>
}
